package com.xtc.netty.io.nio.channel;

import java.io.FileOutputStream;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

public class FileOutputDemo {

    public static final byte[] numbers = {121, 12, 34, 25, 16, 73, 24, 35, 20};

    public static void main(String[] args) {
        try {
            String filePath = "C:\\Users\\Administrator\\Desktop\\百度网盘会员\\FileOutputDemo.txt";

            FileOutputStream fos = new FileOutputStream(filePath);

            FileChannel channel = fos.getChannel();

            ByteBuffer buffer = ByteBuffer.allocate(30);
            for (int i = 0; i < numbers.length; i++) {
                buffer.put(numbers[i]);
            }
            buffer.flip();

            channel.write(buffer);

            fos.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
